import React from 'react'
import Layout from '@/components/layout'
import Post from '@/components/post'
import { getPostBySlug } from '@/lib/apis'
import PostType from '@/types/post'

import type { GetStaticProps, NextPage } from 'next'
export type PostPageProps = {
  post: PostType
}

export type Return = {
  post?: PostType
}

export type Params = {
  slug: string
}

export const getStaticProps: GetStaticProps<Return, Params> = async () => {
  const post = getPostBySlug('about')
  return {
    props: {
      post,
    },
    revalidate: 1,
  }
}

const PostPage: NextPage<PostPageProps> = ({ post }) => {
  return (
    <Layout>
      <Post post={post} />
    </Layout>
  )
}

export default PostPage
